package com.ydd.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.ydd.dto.YddAdvimgPageDTO;
import com.ydd.entity.YddAdvimg;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import com.ydd.vo.YddAdvimgVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
public interface YddAdvimgMapper extends BaseMapper<YddAdvimg> {
    @Select("select * from ydd_advimg where advimgpos=#{advimgpos}")
    public List<YddAdvimg> yddList(String advimgpos);


    /**
     *根据广告位置id统计广告图数量
     * @param id
     * @return
     */
    @Select("select count(advimgpos) from ydd_advimg where advimgpos = #{id}")
    Integer countImg(Integer id);

    /**
     * 广告图分页查询
     * @param yddAdvimgPageDTO
     * @return
     */
    Page<YddAdvimgVO> pageQuery(YddAdvimgPageDTO yddAdvimgPageDTO);

    /**
     * 查询广告图位置
     * @param advimgpos
     * @return
     */
    @Select("select advposname from ydd_advpos where id = #{advimgpos}")
    String query(String advimgpos);

    /**
     * 删除广告图
     * @param id
     */
    @Delete("delete from ydd_advimg where id = #{id}")
    void dropById(Integer id);

    /**
     * 根据id查询广告图
     * @param id
     * @return
     */
    @Select("select * from ydd_advimg where id = #{id}")
    YddAdvimg getById(Integer id);

    /**
     * 修改广告图
     * @param yddAdvimg
     */
    void updateImg(YddAdvimg yddAdvimg);

    /**
     * 添加广告图
     * @param yddAdvimg
     */
    @Insert("insert into ydd_advimg (advimgpos, advimgsrc, advimgdesc, advimglink, default_data) values (#{advimgpos}, #{advimgsrc}, #{advimgdesc},#{advimglink}, #{defaultData})")
    void add(YddAdvimg yddAdvimg);

    /**
     * 统计广告图总数
     * @return
     */
    @Select("select count(*) from ydd_advimg")
    Integer count();
}
